<template>
<div class="layout-app">
	<!-- 悬浮按钮 -->
	<div v-if="isMinimized" class="minimized-button" @click="restoreDialog">
	  <i class="el-icon-message"></i>
	</div>
	<!-- main -->
	<!-- 新增 -->
	<div class="addAcc" ref='myBox' v-if="!isMinimized">
		<el-dialog :title="nameTitle"
		element-loading-text="..."
		element-loading-spinner="el-icon-loading"
		element-loading-background="rgba(141, 141, 141, 0.8)"
		:visible.sync="addDialogVisible" width="68%" v-dialogDrag
		:fullscreen="isFullscreen"
		:show-close="false"
		:before-close="handleClose" custom-class="minimizable-dialog">
		<!-- 在el-dialog的header部分添加自定义内容 -->
		<template slot="title">
		  <div class="dialog-header">
		    <span>{{ nameTitle }}</span>
		    <div class="header-buttons">
				<el-button
				  type="text" 
				  size="medium" 
				  @click="minimizeDialog" 
				  icon="el-icon-minimize"
				  title="最小化">
				</el-button>
		      <el-button 
		        type="text" 
		        size="medium" 
		        @click="toggleFullscreen"
		        :icon="isFullscreen ? 'el-icon-Nofullscreen' : 'el-icon-full-screen'"
		        :title="isFullscreen ? '退出全屏' : '全屏显示'">
		      </el-button>
		      <el-button 
		        type="text" 
		        size="medium" 
		        @click="addDialogVisible = false" 
		        icon="el-icon-close"
		        title="关闭">
		      </el-button>
		    </div>
		  </div>
		</template>
		<!-- tabs -->
		<div class="tabs">
			<div class="tabsMain">
				<!-- 表单 header -->
				<div class="headerForm">
					<el-form ref="addForm" :rules="addFormRules" :model="addForm" label-width="70px" size="mini">
						<el-row :gutter="8">
							<el-col :xs="val.xs" :sm="val.xs" :md="val.md" :lg="val.lg" :xl="val.xl" type="flex" v-for="(val,i) in formType" :key="i">
								<!-- input -->
								<el-form-item v-if="val.type == 'input'" :label="val.label" :prop="val.modelValue">
									<el-input :suffix-icon='val.prefix' v-model="$data.addForm[val.modelValue]" :placeholder="val.placeholder" :disabled="val.disabled" ></el-input>
								</el-form-item>
								<!-- textarea -->
								<el-form-item v-if="val.type == 'textarea'" :label="val.label" :prop="val.modelValue">
									<el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="$data.addForm[val.modelValue]"></el-input>
								</el-form-item>
								<!-- select -->
								<el-form-item v-if="val.type == 'select'" :label="val.label" :prop="val.modelValue">
									<el-select v-model="$data.addForm[val.modelValue]" filterable placeholder="请选择" @focus="sname(val,i)"
									@change="handleChange" :disabled="val.disabled">
										<el-option v-for="item in $data[val.op]" :key="item.id" :label="item.label" :value="item.id" :disabled="item.disabled"> 
										<span style="color: #8492a6; font-size: 12px">{{ item.label }}</span></el-option>
									</el-select>
								</el-form-item>
								<!-- 在selectGYS类型的表单项中添加自定义下拉选项 -->
								<el-form-item v-if="val.type == 'selectGYS'" :label="val.label" :prop="val.modelValue">
								  <el-select 
								    v-model="$data.addForm[val.modelValue]" 
								    filterable 
								    placeholder="请选择" 
								    @focus="sname(val,i)"
								    @change="handleChange" 
								    :disabled="val.disabled">
								    
								    <!-- 自定义下拉选项头部 -->
								    <div slot="prefix" class="custom-select-header">
								      <!-- <span style="color: #606266; font-size: 12px;">没有对应的供应商？</span> -->
								      <el-button 
								        type="text" 
								        size="mini" 
								        icon="el-icon-plus" 
								        @click.stop="openAddSupplierDialog"
								        style="padding: 0 2px;">
								      </el-button>
								    </div>
								    
								    <el-option 
								      v-for="item in $data[val.op]" 
								      :key="item.id" 
								      :label="item.label" 
								      :value="item.id">
								      <span style="color: #8492a6; font-size: 12px">{{ item.label }}</span>
								    </el-option>
								  </el-select>
								</el-form-item>
								<!-- date -->
								<el-form-item v-if="val.type == 'date'" :label="val.label" :prop="val.modelValue">
									<el-date-picker
									:picker-options="pickerOptions" :disabled="val.disabled ? true : false"
									type="date" value-format="yyyy-MM-dd" placeholder="选择日期" v-model="$data.addForm[val.modelValue]">
									</el-date-picker>
								</el-form-item>
								<!-- btn -->
								<el-form-item v-if="val.type == 'btn'">
									<el-button type="primary" plain @click="clickEvents(val,i)">{{ val.label }}</el-button>
								</el-form-item>
							</el-col>
						</el-row>
					</el-form>
				</div>
				<!-- 表单数据！第二层取addForm下的list -->
				<div class="mainForm">
					<el-form ref="addMainForm" :rules="addMainFormRules" :model="addMainForm" label-width="98px" size="mini">
						<el-row :gutter="8">
							<el-col :xs="val.xs" :sm="val.xs" :md="val.md" :lg="val.lg" :xl="val.xl" type="flex" v-for="(val,i) in formMainType" :key="i">
								<!-- input -->
								<el-form-item v-if="val.type == 'input'" :label="val.label" :prop="val.modelValue">
									<el-input :suffix-icon='val.prefix' v-model="$data.addMainForm[val.modelValue]" :disabled="val.disabled" ></el-input>
								</el-form-item>
								<!-- input 数量 -->
								<el-form-item v-if="val.type == 'inputNum'" :label="val.label" :prop="val.modelValue">
									<el-input placeholder="" v-model="$data.addMainForm[val.modelValue]" class="input-with-select" @blur="gotoPrice">
									    <el-select style="width: 108px;" v-model="purcType" slot="prepend" @change="SelectedPurcType" placeholder="库存类型">
									      <el-option label="最小单位" value="1"></el-option>
									      <el-option label="包装单位" value="2"></el-option>
									    </el-select>
									    <span slot="append" icon="el-icon-search">{{ purcType == 1 ? minUnt : unt }}</span>
									  </el-input>
									<!-- <el-input :suffix-icon='val.prefix' v-model="$data.addMainForm[val.modelValue]" @blur="handleInput(val,i)" :disabled="val.disabled" ></el-input> -->
								</el-form-item>
								<!-- textarea -->
								<el-form-item v-if="val.type == 'textarea'" :label="val.label" :prop="val.modelValue">
									<el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="$data.addMainForm[val.modelValue]"></el-input>
								</el-form-item>
								<!-- select -->
								<el-form-item v-if="val.type == 'selectName'" :label="val.label" :prop="val.modelValue">
									<el-select 
									  v-model="$data.addMainForm[val.modelValue]" 
									  filterable 
									  placeholder="请选择" 
									  @focus="foucsSelect(val,i)"
									  @change="handleMainFormChange" 
									  :disabled="val.disabled">
									  <el-group>
									    <!-- 固定头部 -->
									    <div class="select-header" slot="header"
									      style="font-size: 12px;font-weight: bold;display: flex;justify-content: space-around;padding: 8px;text-align: left;
									      position: sticky;top:0;z-index: 10;background-color: #f1f1f1;">
									      <span style="text-align:center;">药品序号</span>
									      <span>药品名称</span>
									      <span>药品规格</span>
									      <span>换算关系</span>
									      <span>参考进价</span>
									      <span>参考售价</span>
									      <span>批准文号</span>
									    </div>
									    
									    <!-- 选项内容 -->
									    <el-option 
									      v-for="item in filteredNameOption" 
									      :key="item.id" 
									      :label="item.label" 
									      :value="item.id"
									      :disabled="item.disabled"> 
									      <div id="optionItem">
									        <span style="text-align:center;">{{ item.id }}</span>
									        <span>{{ item.drugName }}</span>
									        <el-tooltip class="item" effect="light" :content="item.drugSpecifications" placement="top">
									          <span>{{ item.drugSpecifications }}</span>
									        </el-tooltip>
									        <span>{{ '1' + item.pacUnt + '=' + item.pacCnt + item.dosUnt }}</span>
									        <span>{{ item.costPric }}</span>
									        <span>{{ item.costPric }}</span>
									        <span>{{ item.approvalNumber }}</span>
									      </div>
									    </el-option>
									  </el-group>
									</el-select>
								</el-form-item>
								<!-- select -->
								<el-form-item v-if="val.type == 'select'" :label="val.label" :prop="val.modelValue">
									<el-select v-model="$data.addMainForm[val.modelValue]" filterable placeholder="请选择" @focus="foucsSelect(val,i)"
									@change="handleMainFormChangeOther(val,i)" :disabled="val.disabled">
										<el-option v-for="item in $data[val.op]" :key="item.id" :label="item.label" :value="item.id"> 
										<span style="font-size: 12px">{{ item.label }}</span></el-option>
									</el-select>
								</el-form-item>
								<!--  在模板中，生产厂家选择框的配置应该是： -->
								<el-form-item v-if="val.type == 'selectProdent'" :label="val.label" :prop="val.modelValue">
								  <el-select 
								    v-model="$data.addMainForm[val.modelValue]" 
								    filterable 
								    placeholder="请选择" 
								    @focus="foucsSelect(val,i)"
								    @change="handleMainFormChangeOtherP" 
								    :disabled="val.disabled">
								    <el-option 
								      v-for="item in $data[val.op]" 
								      :key="item.id" 
								      :label="item.label" 
								      :value="item.id"
								      :disabled="item.disabled"> <!-- 添加disabled绑定 -->
								      <span style="font-size: 12px" :style="{ color: item.disabled ? '#c0c4cc' : '' }">
								        {{ item.label }}
								      </span>
								    </el-option>
								  </el-select>
								</el-form-item>
								<!-- btn -->
								<el-form-item v-if="val.type == 'tag'">
									<el-tag size="medium">{{ MarkUpTitle + MarkUp }}</el-tag>
								</el-form-item>
								<!-- date -->
								<el-form-item v-if="val.type == 'date'" :label="val.label" :prop="val.modelValue">
									<el-date-picker class="autoWidth" :picker-options="pickerOptions" @focus="dateChoose(i)" @change="getDatePicker"
									type="date" value-format="yyyy-MM-dd" placeholder="选择日期" v-model="$data.addMainForm[val.modelValue]">
									</el-date-picker>
								</el-form-item>
								<!-- btn -->
								<el-form-item v-if="val.type == 'btn'">
									<el-button type="primary" plain @click="clickEvents(val,i)" :disabled="val.disabled">{{ val.label }}</el-button>
								</el-form-item>
							</el-col>
						</el-row>
					</el-form>
				</div>
				<!-- table -->
				<div class="table">
					<el-table :data="tableData" border 
					:style="{ width: tableWidth + 'px' }"
					:row-class-name="tableRowClassName"
					:cell-class-name="tableCellClassName">
						<!-- 字段映射 -->
						<el-table-column prop="drugName" label="药品名称" align='center' width="128"></el-table-column>
						<!-- 入库数量（可编辑） -->
						<el-table-column prop="purcCnt" label="入库数量" width="120">
						  <template slot-scope="scope">
						    <el-input
						      v-if="scope.row.editing"
						      v-model="scope.row.purcCnt"
						      :min="1"
						      :max="99999"
						      size="mini"
						      controls-position="right"
						      @change="handleAmountChange(scope.row)"
						    ></el-input>
						    <span v-else>{{ scope.row.purcCnt }}</span>
							<span v-if="scope.row.purcType === '1'">{{ minUnt }}</span>
							<span v-else>{{ unt }}</span>
						  </template>
						</el-table-column>
						<el-table-column prop="purcPric" label="成本单价" align='center'></el-table-column>
						<el-table-column prop="salePric" label="零售单价" align='center'></el-table-column>
						<el-table-column prop="purcAmt" label="成本金额" align='center'></el-table-column>
						<el-table-column prop="saleAmt" label="零售金额" align='center'></el-table-column>
						<!-- 在el-table-column中添加可编辑列 -->
						<!-- 生产批号（可编辑） -->
						  <el-table-column prop="manuLotnum" label="生产批号" width="120">
						    <template slot-scope="scope">
						      <el-input 
						        v-if="scope.row.editing"
						        v-model="scope.row.manuLotnum"
						        size="mini"
						        placeholder="请输入批号"
						      ></el-input>
						      <span v-else>{{ scope.row.manuLotnum }}</span>
						    </template>
						  </el-table-column>
						  
						  <!-- 生产日期（可编辑） -->
						  <el-table-column prop="manuDate" label="生产日期" width="150">
						    <template slot-scope="scope">
						      <el-date-picker
						        v-if="scope.row.editing"
						        v-model="scope.row.manuDate"
						        type="date"
						        value-format="yyyy-MM-dd"
						        size="mini"
						        placeholder="选择日期"
						      ></el-date-picker>
						      <span v-else>{{ scope.row.manuDate }}</span>
						    </template>
						  </el-table-column>
						  
						  <!-- 有效日期（可编辑） -->
						  <el-table-column prop="expyDate" label="有效日期" width="150">
						    <template slot-scope="scope">
						      <el-date-picker
						        v-if="scope.row.editing"
						        v-model="scope.row.expyDate"
						        type="date"
						        value-format="yyyy-MM-dd"
						        size="mini"
						        placeholder="选择日期"
						      ></el-date-picker>
						      <span v-else>{{ scope.row.expyDate }}</span>
						    </template>
						  </el-table-column>

						<!-- <el-table-column prop="purcCnt" label="入库数量"></el-table-column> -->
						<!-- <el-table-column prop="manuLotnum" label="生产批号"></el-table-column> -->
						<el-table-column prop="minPurcPric" label="成本单价【小单位】" width="168px"></el-table-column>
						<el-table-column prop="minSalePric" label="零售单价【小单位】" width="168px"></el-table-column>
			
						
						<el-table-column prop="putinTypeId" label="入库方式">
							 <template slot-scope="{ row }">
								<!-- 根据加成方式显示不同的title -->
								<span>{{ inStroeMap[row.putinTypeId] || '' }}</span>
							</template>
						</el-table-column>
						<el-table-column prop="purcType" label="库存类型">
							 <template slot-scope="{ row }">
								<!-- 根据加成方式显示不同的title -->
								<span>{{ StroeKindsMap[row.purcType] || '' }}</span>
							</template>
						</el-table-column>
						
						<!-- 循环列 -->
						<el-table-column v-for="(col, inx) in tableRows" :key="inx" :type="col.type" :prop="col.prop" :label="col.name" :width="columnWidth(col, tableData)"></el-table-column>
						<!-- fixed -->
						<el-table-column 
						  fixed="left" 
						  label="行号" 
						  width="68" 
						  align="center">
						  <template slot-scope="scope">
						    {{ scope.$index + 1 }}
						  </template>
						</el-table-column>
						<!-- edit -->
						<el-table-column fixed="right" label="操作" width="148">
							<template slot-scope="scope">
								<div class="editbox" style="text-align: center;">
									<template v-if="!scope.row.editing">
										<el-button type="primary" @click="enableEditing(scope.row)" size="mini">编辑</el-button>
										<el-button :loading="loading" type="danger" @click.native.prevent="deleteRow(scope.$index, tableData)" size="mini">删除</el-button>
									</template>
									<template v-else>
										<el-button :loading="loading" type="success" @click="saveEdit(scope.row)" size="mini">完成</el-button>
										<el-button type="info" @click="cancelEdit(scope.row)" size="mini">取消</el-button>
									</template>
								</div>
							</template>
						</el-table-column>
					</el-table>
					<div class="total">
						<span>成本合计：</span><el-input v-model="cbValue" style="width: 128px;" size="mini" :disabled='totaldisabled'></el-input>
						<span style="margin-left: 12px;">零售合计：</span><el-input v-model="lsValue" style="width: 128px;" size="mini" :disabled='totaldisabled'></el-input>
					</div>
				</div>
			</div>
		</div>
		<!-- 新增提交 -->
		<div slot="footer" class="dialog-footer" v-if="!isEditShow">
			<!-- <el-button :loading="loading" size="mini" :disabled="isEditing" type="warning" plain @click="gotoPlan">采购计划</el-button> -->
			<el-button :loading="loading" size="mini" :disabled="isEditing" type="info" plain @click="draftSubmit">存为草稿</el-button>
			<el-button :loading="loading" size="mini" :disabled="isEditing" type="primary" plain @click="addSubmit">保存提交</el-button>
			<el-button :loading="loading" size="mini" :disabled="isEditing" plain @click="minimizeDialog">最小化</el-button>
		</div>
		<!-- 编辑提交 -->
		<div slot="footer" class="dialog-footer" v-if="isEditShow">
			<!-- <el-button :loading="loading" size="mini" type="warning" plain @click="gotoPlan">采购计划</el-button> -->
			<el-button :loading="loading" size="mini" type="info" plain @click="draftEditSubmit">修改保存草稿</el-button>
			<el-button :loading="loading" size="mini" type="primary" plain @click="editSubmit">修改提交</el-button>
			<el-button :loading="loading" size="mini" plain @click="minimizeDialog">最小化</el-button>
		</div>
	</el-dialog>
	</div>
	<!-- 内层Model -->
	<div class="innerModel">
		<el-dialog width="48%" title="采购计划选择列表" v-dialogDrag :visible.sync="innerVisible"
		element-loading-text="添加中" element-loading-spinner="el-icon-more-outline">
			<div class="innerModel-header">
				<!-- dateTimer -->
				<span>业务日期:</span>
				<el-date-picker v-model="startDate" type="datetime" size="mini" style="margin-left: 8px;" placeholder="选择开始时间"
					:picker-options="pickerOptions"> 
				</el-date-picker>
				<el-date-picker v-model="endDate" type="datetime" style="margin-left: 8px;" size="mini" placeholder="选择结束时间"
					:picker-options="pickerOptions">
				</el-date-picker>
				<el-button :loading="loading" size="mini" type="primary" plain @click="changeData" style="margin-left: 8px;">刷新</el-button>
			</div>
			<div class="innerModel-table" style="margin-top: 8px;">
				<el-table :data="innertableData" v-loading="loading" ref="singleTable" border @row-dblclick="handledbRow"
					highlight-current-row @current-change="handleCurrentTableChange">
					<!-- 表格行rows -->
					<el-table-column prop="id" label="系统序号"></el-table-column>
					<el-table-column prop="status" label="状态">
						<template slot-scope="{ row }">
							<!-- 根据state显示不同的图标 -->
							<i :class="statusIconMap[row.state]" :style="{ color: statusColorMap[row.state] }"></i>
							<span>{{ statusMap[row.state] || '未知状态' }}</span>
						</template>
					</el-table-column>
					<el-table-column v-for="(col, inx) in innertableDataRows" :key="inx" :type="col.type" :prop="col.prop" :label="col.name" :width="innerColumnWidth(col, innertableData)"></el-table-column>
					<!-- fixed -->
					<el-table-column fixed="left" label="行号" type="index" width="48" align="center"></el-table-column>
				</el-table>
				<!-- 分页 -->
				<el-pagination
				style="margin: 12px;"
				@size-change="handleSizeChange"
				@current-change="handleCurrentChange"
				:current-page="pageNum"
				:page-sizes="[6, 12, 48]"
				:page-size="pageSize"
				:total="totalSize"
				layout="total, sizes, prev, pager, next, jumper"
				background
				>
				</el-pagination>
			</div>
			<div slot="footer" class="dialog-footer" v-if="!isEditShow">
				<el-button :loading="loading" size="mini" type="warning" plain @click="watchData">查看单据</el-button>
				<el-button :loading="loading" size="mini" type="primary" plain @click="chooseData">选择</el-button>
				<el-button :loading="loading" size="mini" plain @click="innerVisible = false">关闭</el-button>
			</div>
		</el-dialog>
	</div>
	<!-- 查看单据Model -->
	<div class="WatchModel">
		<el-dialog width="48%" title="查看计划" v-dialogDrag :visible.sync="tableWatchDataDialog"
		element-loading-text="加载中" element-loading-spinner="el-icon-more-outline">
			<div class="innerModel-header">
				<!-- dateTimer -->
				<span>业务日期:</span>
				<el-date-picker v-model="startDate" type="datetime" size="mini" style="margin-left: 8px;" placeholder="选择开始时间"
					:picker-options="pickerOptions"> 
				</el-date-picker>
				<el-date-picker v-model="endDate" type="datetime" style="margin-left: 8px;" size="mini" placeholder="选择结束时间"
					:picker-options="pickerOptions">
				</el-date-picker>
				<el-button :loading="loading" size="mini" type="primary" plain @click="changeData" style="margin-left: 8px;">刷新</el-button>
			</div>
			<div class="innerModel-table" style="margin-top: 8px;">
				<el-table :data="tableWatchData" v-loading="loading" border>
					<!-- 表格行rows -->
					<el-table-column prop="id" label="系统序号"></el-table-column>
					<el-table-column prop="status" label="状态">
						<template slot-scope="{ row }">
							<!-- 根据state显示不同的图标 -->
							<i :class="statusIconMap[row.state]" :style="{ color: statusColorMap[row.state] }"></i>
							<span>{{ statusMap[row.state] || '未知状态' }}</span>
						</template>
					</el-table-column>
					<el-table-column v-for="(col, inx) in tableWatchDataRows" :key="inx" :type="col.type" :prop="col.prop" :label="col.name" :width="WatchColumnWidth(col, innertableData)"></el-table-column>
					<!-- fixed 在表格列定义中修改行号显示 -->
					<el-table-column 
					  fixed="left" 
					  label="行号" 
					  width="68" 
					  align="center">
					  <template slot-scope="scope">
					    {{ scope.$index + 1 }}
					  </template>
					</el-table-column>
				</el-table>
			</div>
			<div slot="footer" class="dialog-footer">
				<el-button :loading="loading" size="mini" plain @click="tableWatchDataDialog = false">关闭</el-button>
			</div>
		</el-dialog>
	</div>
	<!-- 在模板底部添加新增供应商对话框 -->
		  <el-dialog
		    title="新增供应商"
			:visible.sync="addSupplierDialogVisible"
		    width="48%"
		  	top="18px"
		    @close="handleSupplierDialogClose"
		  >
		    <el-form
		      ref="supplierForm"
		      :model="supplierForm"
		      :rules="rules"
		      label-width="120px"
		      label-position="right"
		    >
		      <el-form-item label="供应商名称" prop="supplierName">
		        <el-input
		  			  size="mini"
		          v-model="supplierForm.supplierName"
		          placeholder="请输入供应商名称"
		          clearable
		        />
		      </el-form-item>
		  
		      <el-form-item label="联系人" prop="contact">
		        <el-input
		  			  size="mini"
		          v-model="supplierForm.contact"
		          placeholder="请输入联系人姓名"
		          clearable
		        />
		      </el-form-item>
		  
		      <el-form-item :label="phoneType === 'mobile' ? '手机号：' : '座机号：'" prop="contactPhone">
		        <el-input
					size="mini"
		          v-model="supplierForm.contactPhone"
		          placeholder="请输入手机号或座机号"
		          @blur="handlePhoneBlur"
		          clearable
		        />
		      </el-form-item>
		  
		      <el-form-item label="许可证号" prop="permitNumber">
		        <el-input
		  			  size="mini"
		          v-model="supplierForm.permitNumber"
		          placeholder="请输入许可证号"
		          clearable
		        />
		      </el-form-item>
		  
		      <el-form-item label="地址" prop="address">
		        <el-input
		  			  size="mini"
		          v-model="supplierForm.address"
		          placeholder="请输入详细地址"
		          clearable
		        />
		      </el-form-item>
		  
		      <el-form-item label="状态" prop="status">
		        <el-radio-group v-model="supplierForm.status">
		          <el-radio :label="1">启用</el-radio>
		          <el-radio :label="2">禁用</el-radio>
		        </el-radio-group>
		      </el-form-item>
		  
		      <el-form-item label="备注" prop="remark">
		        <el-input
		  			  size="mini"
		          v-model="supplierForm.remark"
		          type="textarea"
		          :rows="3"
		          placeholder="请输入备注信息"
		        />
		      </el-form-item>
		    </el-form>
		  
		    <div slot="footer" class="dialog-footer">
		      <el-button size="mini" type="primary" @click="handleSubmit" :loading="loading">确 定</el-button>
		      <el-button size="mini" @click="addSupplierDialogVisible = false">取 消</el-button>
		    </div>
	
		</el-dialog>

</div>
</template>

<script>
// self
import AccType from './AddRukuType.js'
import AccMainType from './AddRukuTypeMain.js'
import addForm from './addForm.js' //Form表单
// prop

// ext
import { getLunar } from 'chinese-lunar-calendar'

// 接口
// import { 
// 	getPurchasingPlan,toExamineTcm,getPlans,selectDropDownList,getWare,
// 	dugDocgetDrugDetails,getManufacturer,getDocMark,
// 	dugDocInsert
//  } from "@/api/systemCatalogue/traMedici.js";
 
 import { getProdent,getWare,selectDropDownList,getDocMark } from "@/api/PSI.js";
 import { addSupplierEntity,SupplierDetails,editSupplierEntity }  from "@/api/supplier.js";
 import { dugDocPutin,dugDocInsert,dugDocdugDocgetDrugDetails,editdugDoc } from "@/api/MedicenHouse/Western.js";
	
export default {
	props: ['parentMethod'],
	inject: ['reload'], // 无痕刷新
	components:{
		
	},
	data(){
		return{
			isMinimized: false, // 确保这是直接返回的顶层属性
			isEditing: false, // 控制是否处于编辑状态
			//str
			tableWidth:'', //右侧表格动态宽度
			value:'',
			purcType:'2', // 库存类型 = > 判断大小单位 0最小单位,1包装单位
			nameTitle:'新增【西药房】其他入库',
			// 新增全屏状态
			isFullscreen: false,
			expyDate:'',
			MarkUpTitle:'',
			unt:'', // 包装单位 （数量：盒？包？g?）
			minUnt:'', // 最小单位 （数量：盒？包？g?）
			inputSearchValue:'',
			deptCode:'',
			userId:'', // 制单人Id,取当然操登录用户I的.用于后端不反的情况下使用
			getLunarDay: '',
			areaCode:'',
			areaPName:'',
			appId:'', // * 选择采购计划时的Id
			startDate:'', // * 开始时间
			endDate:'', // * 结束时间
			idx:'',
			MarkUp:'', // 加成率
			cbValue:'', // 成本合计
			lsValue:'', // 零售合计
			currentCell: null, // 单元格隐藏
			year: new Date().getFullYear(),
			month: new Date().getMonth() + 1,
			date: new Date().getDate(),
			lunarDate: '',//农历
			// 1 - 3
			firstName:'',
			seconedName:'',
			thirdName:'',
			auditStatus:'5',
			currentRow: null, //单选高亮
			//num
			pacValue:0, // 换算关系
			pageNum: 1, //当前页currentPage
			pageSize: 6,
			totalSize: 10, //总条数
			//ble
			loading:false,
			disabled:true,
			totaldisabled:true,
			addSupplierDialogVisible: false,
			supplierForm: {
			  supplierName: '',
			  contact: '',
			  contactPhone: '',
			  permitNumber: '',
			  address: '',
			  status: 1, // 默认启用
			  remark: ''
			},
			addghdwDialog:false,
			isEditShow:false,
			addDialogVisible: false, //新增采购入库model
			dialogFormVisible:false,
			innerVisible:false, //内层Model选择采购计划
			tableWatchDataDialog:false, // 查看单据表格
			//arr
			tableWatchData:[], // 查看单据表格
			formType:[], // 表单头部内容
			formMainType:[], // 表单主体内容
			tableData:[],
			tableRows:[
				{ name:"规格描述", prop:"drugSpec", type:"" },{ name:"生产厂家", prop:"prodentpName", type:"" },
			],
			innertableData:[], //内层采购计划数据源
			currentObj:{}, //内层采购计划数据源 = > 单击选择
			currentTable: [],//表格单选
			innertableDataRows:[
				{ name:"单据编号", prop:"docNum"},{ name:"业务日期", prop:"busDate" },
				{ name:"供货单位", prop:"supplierName" },
				{ name:"合计金额", prop:"totalAmt" },{ name:"制单人", prop:"reviewName"},{ name:"制单时间", prop:"reviewTime"},
				{ name:"审核人", prop:"passingOrdersName" },{ name:"审核时间", prop:"passingOrdersTime" }
			],
			tableWatchDataRows:[
				{ name:"药品名称", prop:"drugName"},{ name:"规格", prop:"drugSpec" },
				{ name:"计划id", prop:"planId" },{ name:"单价", prop:"purcPric"},
				{ name:"计划数量", prop:"purcCnt" },
			],
			selectOption:[{id:3,label:'西药房',value:'西药房'}],//库房
			prodentOption:[],//生产厂家下拉选择框
			ghdwOption:[
				{id:1,label:'水富市人民医院',value:'水富市人民医院'},{id:2,label:'昆明灵泽科技有限公司',value:'昆明灵泽科技有限公司'},
			],
			cgOption:[
				{id:1,label:'集中采购',value:'集中采购'},{id:2,label:'谈判药品',value:'谈判药品'},{id:3,label:'带量采购',value:'带量采购'},
				{id:4,label:'备案采购',value:'备案采购'},{id:5,label:'非平台采购',value:'非平台采购'},{id:6,label:'精麻药品',value:'精麻药品'},
				{id:7,label:'直接采购-国产非中选',value:'直接采购-国产非中选'},{id:8,label:'省际联盟带量采购',value:'省际联盟带量采购'},
				{id:9,label:'国家带量采购',value:'国家带量采购'},{id:10,label:'省级带量采购',value:'省级带量采购'}
			],
			// 表单验证规则 header
			addFormRules:{
				shedId: [{ required: true, message: '请先选择要入库的库房！', trigger: 'change' }],
				supplyCandidateId: [{ required: true, message: '请选择供货单位！', trigger: 'change' }],
				// 示例：号码验证
				purcInvoCodg: [
				    { required: false, message: '请输入发票号！', trigger: 'blur' },
				    { 
				      pattern: /^\w+$/,  // 正则验证
				      message: '可输入：字母/数字/下划线',
				      trigger: 'blur'
				    }
				],
				supplyCode: [
				    { required: false, message: '请输入供货号！', trigger: 'blur' },
				    { 
				      pattern: /^\w+$/,  // 正则验证
				      message: '可输入：字母/数字/下划线',
				      trigger: 'blur'
				    }
				],
			},
			rules: {
			  supplierName: [
			    { required: true, message: '请输入供应商名称', trigger: 'blur' },
			    { min: 2, max: 50, message: '长度在 2 到 50 个字符', trigger: 'blur' }
			  ],
			  contact: [
			    { required: false, message: '请输入联系人姓名', trigger: 'blur' },
			    { min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
			  ],
			  contactPhone: [
				  { 
					validator: this.validatePhone, 
					trigger: 'blur',
					required: true,
				  }
				],
			  permitNumber: [
			    { required: false, message: '请输入许可证号', trigger: 'blur' }
			  ],
			  address: [
			    { required: false, message: '请输入详细地址', trigger: 'blur' }
			  ]
			},
			// 表单验证规则 main
			addMainFormRules:{
				drugId: [{ required: true, message: '请先选择药品信息！', trigger: 'change' }],
				manuDate: [{ required: true, message: '请选择药品的生产日期', trigger: 'change' }],
				expyDate: [{ required: true, message: '请选择药品的有效日期', trigger: 'change' }],
				purcType: [{ required: true, message: '请先选择库存类型！', trigger: 'change' }],
				manuLotnum: [
					{ required: true, message: '请输入药品的生产批号！', trigger: 'blur' },
					{ 
					  pattern: /^\w+$/,  // 正则验证
					  message: '格式错误！(字母/数字)',
					  trigger: 'blur'
					}
				],
				purcCnt: [
				    { required: true, message: '入库的数量为必填项！', trigger: 'blur' },
				    { 
				      validator: (rule, value, callback) => {
				        // 验证是否为非0正整数
				        if (!/^[1-9][0-9]*$/.test(value)) {
				          callback(new Error('入库的数量为非0正整数!'));
				        } else {
				          callback();
				        }
				      },
				      trigger: 'blur'
				    }
				],
			},
			addWaysMap: {
				1: '不加成',
				2: '固定加成',
				3: '比例加成',
				4: '手工比例加成',
			},
			inStroeMap:{
				1: '采购入库',
				2: '其他入库',
				3: '赠送入库',
				4: '盘点单位',
				5: '系统切换入库',
			},
			// 库存类型
			StroeKindsMap:{
				'1': '最小单位',
				'2': '包装单位',
			},
			// 单据状态 0 草稿,1 回退提交,2 已提交,3 回退审核,4 已审核,5 已过单,6 已作废'
			statusOption:[
				{id:0,label:'草稿'},{id:1,label:'回退提交'},{id:2,label:'已提交'},{id:3,label:'回退审核'},{id:4,label:'已审核'},{id:5,label:'已过单'},{id:6,label:'已作废'},
			],
			sexOptions:[{id:1,label:'男',value:'男'},{id:2,label:'女',value:'女'}],
			marryiedOptions:[{id:1,label:'未婚',value:'未婚'},{id:2,label:'已婚',value:'已婚'},{id:3,label:'离异',value:'离异'},{id:4,label:'丧偶',value:'丧偶'},{id:5,label:'再婚',value:'再婚'}],
			nameOption:[],
			
			//obj
			addForm:{}, // form表单 * 
			addMainForm:{}, // form主体表单 * addForm.list
			oldData:{},
			lists:{},
			options:[],
			// 添加状态变量
			phoneType: 'mobile', // 默认手机号类型
			 // 入库方式
			rkWaysOptions:[
				{id:1,label:'采购入库',value:'采购入库',disabled:true},{id:2,label:'其他入库',value:'其他入库'},
				{id:3,label:'赠送入库',value:'赠送入库'},{id:4,label:'盘点入库',value:'盘点入库'},{id:5,label:'系统切换入库',value:'系统切换入库'}
			],
			// 加成方式
			MarkOption:[
				{ id:0,label:'不加成',value:'不加成'},{ id:1,label:'固定加成',value:'固定加成'},
				{ id:2,label:'比例加成',value:'比例加成'},{ id:3,label:'手工比例加成',value:'手工比例加成'}
			],
			// 药品加成率
			WesternMarks:[],
			ssrOption:[],
			gysOption:[],
			ManufacturerOptions:[],
			//props
			pickerOptions: {},
			manuDatePickerOptions: {
				disabledDate(time) { return time.getTime() > Date.now() },
				shortcuts: [
					{ text: '今天', onClick(picker) { picker.$emit('pick', new Date()); }}, 
					{ text: '昨天', onClick(picker) { const date = new Date();date.setTime(date.getTime() - 3600 * 1000 * 24);picker.$emit('pick', date);}}, 
					{ text: '一周前',onClick(picker) {const date = new Date();date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);picker.$emit('pick', date);}},
					{ text: '最近一个月',onClick(picker) {const date = new Date();date.setTime(date.getTime() - 3600 * 1000 * 24 * 30);picker.$emit('pick', date);}},
					{ text: '最近三个月',onClick(picker) {const date = new Date();date.setTime(date.getTime() - 3600 * 1000 * 24 * 90);picker.$emit('pick', date);}},
					{ text: '半年前',onClick(picker) {const date = new Date();date.setTime(date.getTime() - 3600 * 1000 * 24 * 180);picker.$emit('pick', date);}},
					{ text: '去年',onClick(picker) {const date = new Date();date.setTime(date.getTime() - 3600 * 1000 * 24 * 360);picker.$emit('pick', date);}},
				]
			},
			expyDatePickerOptions: {
				disabledDate(time) { return time.getTime() < Date.now() },
				shortcuts: [
					{ text: '三个月后',onClick(picker) {const date = new Date();date.setTime(date.getTime() + 3600 * 1000 * 24 * 90);picker.$emit('pick', date);}},
					{ text: '半年后',onClick(picker) {const date = new Date();date.setTime(date.getTime() + 3600 * 1000 * 24 * 180);picker.$emit('pick', date);}},
					{ text: '明年',onClick(picker) {const date = new Date();date.setTime(date.getTime() + 3600 * 1000 * 24 * 360);picker.$emit('pick', date);}},
					{ text: '后年',onClick(picker) {const date = new Date();date.setTime(date.getTime() + 3600 * 1000 * 24 * 720);picker.$emit('pick', date);}},
					{ text: '三年后',onClick(picker) {const date = new Date();date.setTime(date.getTime() + 3600 * 1000 * 24 * 360 * 3);picker.$emit('pick', date);}},
					{ text: '五年后',onClick(picker) {const date = new Date();date.setTime(date.getTime() + 3600 * 1000 * 24 * 360 * 5);picker.$emit('pick', date);}},
					{ text: '十年后',onClick(picker) {const date = new Date();date.setTime(date.getTime() + 3600 * 1000 * 24 * 360 * 10);picker.$emit('pick', date);}},
				]
			},
			statusMap: {
				0: '草稿',
				1: '回退提交',
				2: '已提交',
				3: '回退审核',
				4: '已审核',
				5: '已过单',
				6: '已作废'
			},
			statusIconMap: {
				0: 'el-icon-document',
				1: 'el-icon-top-left',
				2: 'el-icon-check',
				3: 'el-icon-bottom-right',
				4: 'el-icon-document-checked',
				5: 'el-icon-success',
				6: 'el-icon-delete'
			},
			statusColorMap: {
				0: '#909399',
				1: '#67C23A',
				2: '#409EFF',
				3: '#E6A23C',
				4: '#409EFF',
				5: '#409EFF',
				6: '#F56C6C'
			},
			// 在data中添加watch属性 , 使表格能随着 addMainForm 的变化而更新数据。主要需要修改 enableEditing 方法和添加对 addMainForm 的监听。
			watch: {
			  // 保留原有的watch方法
			  addMainForm: {
			    handler(newVal) {
			      if (this.oldData && this.oldData.editing) {
			        const index = this.tableData.findIndex(item => item.drugId === this.oldData.drugId);
			        if (index !== -1) {
			          this.tableData.splice(index, 1, {...newVal, editing: true});
			        }
			      }
			    },
			    deep: true
			  },
			},
		}
	},
	// 在data中添加一个计算属性来过滤nameOption
	// 修改计算属性
	computed: {
	  // 不再根据表格数据禁用药品选项
	  filteredNameOption() {
	    return this.nameOption.map(item => ({
	      ...item,
	      disabled: false // 所有药品选项都不禁用
	    }));
	  },
	  
	  // 新增计算属性：禁用的生产厂家选项
	  disabledManufacturers() {
	    const disabledIds = [];
	    this.tableData.forEach(row => {
	      // 如果当前表单中的药品ID和名称与表格中某行相同
	      if (this.addMainForm.drugId === row.drugId && 
	          this.addMainForm.drugName === row.drugName) {
	        // 将该行对应的生产厂家ID加入禁用列表
	        if (row.prodentpNameId) {
	          disabledIds.push(row.prodentpNameId);
	        }
	      }
	    });
	    return disabledIds;
	  }
	},
	watch:{
		// 新增对成本单价的监听，确保即时响应
		'addMainForm.purcPric': {
		  handler(newVal, oldVal) {
		    if (newVal !== undefined && newVal !== null && newVal !== oldVal) {
		      this.$nextTick(() => {
		        this.updateAllPrices();
		      });
		    }
		  },
		  immediate: true
		}
	},
	created() {
		
	},
	mounted() {
		// 初始化状态
		this.isMinimized = false;
		// 获取接口参数
		this.getAddForm();
		// 获取当前日期时间
		this.getNowDateTime();		
		// console.log(this.addForm.busDate);
		this.getGys();
		this.getDrugWare();
	},
	methods:{
		// 采购计划数据
		async loadData(){
			let res = await getPlans({
				pageNum:this.pageNum,
				pageSize:this.pageSize,
				startDate:this.startDate,
				endDate:this.endDate,
			});
			if(res.code == 200){
				this.innertableData = res.data
				this.totalSize = res.data.totalSize
				console.log(res.data,'res.datares.datares.datares.datares.datares.datares.data');
			}else{
				this.$message({type: 'error',message: res.message});
			}
		},
		// 将当前日期时间设置为夜晚十一点五十九分
		getNowDateTime(){
			// 获取当前日期时间、
			this.addForm.createTime = new Intl.DateTimeFormat('zh-CN').format(new Date()).replace(/\//g, '-');
			// 赋值业务日期
			this.addForm.busDate = new Intl.DateTimeFormat('zh-CN').format(new Date()).replace(/\//g, '-');
			// 获取终端序号 => 当前登录用户
			this.addForm.terminalId = localStorage.getItem('terminalId');
		},
		// 获取制单人 => 当前登录用户
		getCreateId(){
			this.addForm.createId = JSON.parse(localStorage.getItem('userInfo')).userId;
		},
		// 采购计划数据按钮
		gotoPlan(){
			this.innerVisible = true;
			this.getDrugWare();
			this.loadData();
		},
		/* 内层Model */
		// 内层刷新按钮
		changeData(){
			this.loading = true;
			setTimeout(()=>{
				this.loadData();
				this.loading = false;
			},888)
		},
		// 新增切换全屏方法
		toggleFullscreen() {
		  this.isFullscreen = !this.isFullscreen;
		},
		// 表格单选 => getPlans
		handleCurrentTableChange(val){
			if(val.state != 5){
				this.setCurrent();
				this.$message({ type: 'error', message: '只能选择已过单数据!'});
			}else{
				// 赋id
				this.appId = val.id
				this.currentTable = val
				this.$message({ type: 'success', message: '已选择:' + this.appId + '的采购计划数据'});
			}
		},
		async getGys(){
			// 供应商下拉列表
			let rs = await selectDropDownList();
			this.gysOption = rs.data.content.map(obj => {
			  // 将 name 替换为 label，并保留其他字段
			  return { label: obj.supplierName , ...obj };
			});
		},
		async getDrugWare(){
		  // 药品数据下拉列表
		  let res = await getWare();
		  console.log(res.data,'药品数据下拉列表药品数据下拉列表');
		  if(res.code===200){
		    this.nameOption = res.data.content.map(obj => {
		      // 将 name 替换为 label，并保留其他字段
		      return { label: obj.drugName , ...obj };
		    });
		    // 强制更新视图，确保下拉选项状态正确
		    this.$forceUpdate();
		  }	
		},
		// 更新所有价格字段的方法
		  updateAllPrices() {
		    // 确保有有效的成本单价和药品信息
		    if (!this.addMainForm.purcPric || !this.addMainForm.drugId) return;
		
		    // 获取当前药品信息
		    const drugInfos = this.filteredNameOption.find(item => item.id === this.addMainForm.drugId);
		    if (!drugInfos || !drugInfos.pacCnt) return;
		
		    // 1. 更新成本单价相关字段
		    // 大单位成本单价 = 成本单价本身
		    this.addMainForm.maxPurcPric = Number(this.addMainForm.purcPric).toFixed(2);
		    // 小单位成本单价 = 成本单价 / 包装数量
		    this.addMainForm.minPurcPric = (Number(this.addMainForm.purcPric) / drugInfos.pacCnt).toFixed(2);
		
		    // 2. 根据加成方式计算销售单价
		    let salePric;
		    switch(drugInfos.markUpId) {
		      case 1: // 比例加成
		        salePric = Number(this.addMainForm.purcPric) * (drugInfos.markUpRate);
		        this.MarkUpTitle = '比例加成:';
		        this.MarkUp = drugInfos.markUpRate;
		        break;
		        
		      case 2: // 固定加成
		        salePric = Number(this.addMainForm.purcPric) + Number(drugInfos.markUpPric);
		        this.MarkUpTitle = '固定加成金额:';
		        this.MarkUp = drugInfos.markUpPric;
		        break;
		        
		      case 3: // 手工比例加成
		        salePric = Number(this.addMainForm.purcPric) * (parseFloat(drugInfos.markUpRate) / 100)
		        this.MarkUpTitle = '手工比例加成:';
		        this.MarkUp = drugInfos.markUpRate;
		        break;
		        
		      default: // 不加成
		        salePric = Number(this.addMainForm.purcPric);
		        this.MarkUpTitle = '不加成';
		        this.MarkUp = 1;
		    }
		    this.addMainForm.salePric = salePric;
		
		    // 3. 更新销售单价相关字段
		    // 大单位销售单价 = 销售单价本身
		    this.addMainForm.maxSalePric = salePric;
		    // 小单位销售单价 = 销售单价 / 包装数量
		    this.addMainForm.minSalePric = (salePric / drugInfos.pacCnt).toFixed(2);
		
		    // 4. 如果有入库数量，则更新金额字段
		    if (this.addMainForm.purcCnt) {
		      this.addMainForm.purcAmt = (Number(this.addMainForm.purcPric) * Number(this.addMainForm.purcCnt)).toFixed(2);
		      this.addMainForm.saleAmt = (salePric * Number(this.addMainForm.purcCnt)).toFixed(2);
		    }
		    
		    // 5. 强制更新视图
		    this.$forceUpdate();
		  },
			// 处理其他选择框变化
			handleMainFormChangeOther(val, i) {

			},
			// 验证联系电话（支持手机号和座机号）
			  validatePhone(rule, value, callback) {
			    if (!value) {
			      return callback(new Error('请输入联系电话'));
			    }
			    
			    // 手机号正则
			    const mobileReg = /^1[3-9]\d{9}$/;
			    // 座机号正则（支持带区号，如010-12345678或12345678）
			    const telReg = /^(0\d{2,3}-)?\d{7,8}$/;
			    
			    if (mobileReg.test(value)) {
			      this.phoneType = 'mobile';
			      callback();
			    } else if (telReg.test(value)) {
			      this.phoneType = 'tel';
			      callback();
			    } else {
			      callback(new Error('请输入正确的手机号或座机号'));
			    }
			  },
			  // 联系电话失焦处理
			    handlePhoneBlur() {
			      // 触发验证
			      this.$refs.supplierForm.validateField('contactPhone', (error) => {
			        if (!error) {
			          // 验证通过后强制更新视图
			          this.$forceUpdate();
			        }
			      });
			    },
			// 生产厂家选择变化处理
			handleMainFormChangeOtherP(val) {
			  console.log('生产厂家选择变化:', val);
			  
			  // 1. 从生产厂家选项中查找选中的厂家
			  const selectedManufacturer = this.prodentOption.find(item => item.id === val);
			  
			  if (selectedManufacturer) {
			    // 2. 填充生产厂家名称和ID
			    this.addMainForm.prodentpName = selectedManufacturer.label; // 厂家名称
			    this.addMainForm.prodentpNameId = selectedManufacturer.id; // 厂家ID
			    
			    // 3. 不再在这里计算有效期，而是直接赋值
			    // 如果已经有有效期数据，则保留原值
			    // if (!this.addMainForm.expyDate) {
			    //   this.expyDate = this.addMainForm.expyDate; // 或者设置为默认值
			    // }
			    this.expyDate = selectedManufacturer.expyDate; // 有效期
				console.log(this.expyDate,'this.expyDate');
			    this.$message.success(`已选择生产厂家: ${selectedManufacturer.label}`);
			  } else {
			    this.$message.error('未找到对应的生产厂家信息');
			  }
			  
			  // 强制更新视图
			  this.$forceUpdate();
			},

		  // 修改药品选择变化处理方法
		  async handleMainFormChange(val) {
		    // 获取选中的药品信息
		      const drugInfos = this.filteredNameOption.find(item => item.id === val);
		      if (!drugInfos) return;
		    
		      // 更新基础信息
		      this.addMainForm.drugId = drugInfos.id;
		      this.addMainForm.drugSpec = drugInfos.drugSpecifications;
		      this.addMainForm.drugName = drugInfos.drugName;
		      this.addMainForm.pacName = drugInfos.pacName;
		      
		      this.addMainForm.markUpId = drugInfos.markUpId;
		      this.addMainForm.markUpName = drugInfos.markUpName;
		      this.addMainForm.markUpRate = drugInfos.markUpRate;
		      this.addMainForm.markUpPric = drugInfos.markUpPric;
		      
		      // 调用接口获取生产厂家信息
		      try {
		        const res = await getProdent({ drugId: val });
		        if (res.code === 200) {
		          // 1. 获取当前表格中相同药品的厂家ID列表
		          const disabledManufacturerIds = this.tableData
		            .filter(item => item.drugId === val && item.drugName === drugInfos.drugName)
		            .map(item => item.prodentpNameId);
		          
		          // 2. 更新生产厂家下拉选项，并设置禁用状态
		          this.prodentOption = res.data.map(item => ({
		            id: item.prodentpId,
		            label: item.prodentpName,
		            disabled: disabledManufacturerIds.includes(item.prodentpId), // 根据是否存在于表格中设置禁用状态
		            ...item
		          }));
		          
		          // 3. 启用生产厂家下拉框
		          this.formMainType.forEach(item => {
		            if (item.modelValue === 'prodentpName') {
		              item.disabled = false;
		            }
		          });
		          
		          // 4. 默认选择第一个未禁用的厂家
		          const firstEnabled = this.prodentOption.find(item => !item.disabled);
		          if (firstEnabled) {
		            this.addMainForm.prodentpName = firstEnabled.label;
		            this.addMainForm.prodentpNameId = firstEnabled.id;
		          } else if (this.prodentOption.length > 0) {
		            // 如果没有未禁用的厂家，选择第一个并提示
		            this.addMainForm.prodentpName = this.prodentOption[0].label;
		            this.addMainForm.prodentpNameId = this.prodentOption[0].id;
		            this.$message.warning('该药品的所有生产厂家已在表格中存在');
		          }
		        }
		      } catch (error) {
		        console.error('获取生产厂家失败:', error);
		      }
		    
		    // 原有逻辑保持不变...
		    this.addMainForm.markUpId = drugInfos.markUpId;
		    this.addMainForm.markUpName = drugInfos.markUpName;
		    this.addMainForm.markUpRate = drugInfos.markUpRate;
		    this.addMainForm.markUpPric = drugInfos.markUpPric;
		    
		    this.addMainForm.drugId = drugInfos.id;
		    this.addMainForm.drugSpec = drugInfos.drugSpecifications;
		    this.addMainForm.drugName = drugInfos.drugName;
		    this.addMainForm.pacName = drugInfos.pacName;
		    this.addMainForm.prodentpNameId = drugInfos.manufacturerId;
		    this.addMainForm.prodentpName = drugInfos.manufacturerName;
		    this.addMainForm.approvalNumber = drugInfos.approvalNumber;
		    this.addMainForm.markUpId = drugInfos.markUpId;
		    this.addMainForm.putinTypeId = this.addForm.putinTypeId;
		    this.addMainForm.pacCnt = drugInfos.pacCnt;
		    this.unt = drugInfos.pacUnt;
		    this.minUnt = drugInfos.dosUnt;
		    this.expyDate = drugInfos.expyDate;
		    
		    // 设置成本单价
		    const costPric = Number(drugInfos.costPric);
		    this.addMainForm.purcPric = costPric;
		    
		    // 根据加成方式计算销售单价
		    let salePric = costPric;
		    switch(drugInfos.markUpId) {
		      case 1: // 比例加成
		      case 3: // 手工比例加成
		        salePric = costPric + (costPric * drugInfos.markUpRate);
		        this.MarkUpTitle = '比例加成:';
		        this.MarkUp = drugInfos.markUpRate;
		        break;
		        
		      case 2: // 固定加成
		        salePric = costPric + drugInfos.markUpPric;
		        this.MarkUpTitle = '固定加成金额:';
		        this.MarkUp = drugInfos.markUpPric;
		        break;
		        
		      case 4: // 不加成
		      default:
		        salePric = costPric;
		        this.MarkUpTitle = '不加成';
		        this.MarkUp = 0;
		    }
		    this.addMainForm.salePric = salePric;
		    
		    // 计算单位价格
		    const pacCnt = Number(drugInfos.pacCnt) || 1;
		    
		    // 大单位成本单价 = 成本单价
		    this.addMainForm.maxPurcPric = costPric.toFixed(2);
		    
		    // 小单位成本单价 = 成本单价 / 包装数量
		    this.addMainForm.minPurcPric = (costPric / pacCnt).toFixed(2);
		    
		    // 大单位销售单价 = 销售单价
		    this.addMainForm.maxSalePric = salePric;
		    
		    // 小单位销售单价 = 销售单价 / 包装数量
		    this.addMainForm.minSalePric = (salePric / pacCnt).toFixed(2);
		    
		    // 自动填充入库数量为1
		    this.addMainForm.purcCnt = 1;
		    
		    // 计算金额
		    this.addMainForm.purcAmt = costPric.toFixed(2);
		    this.addMainForm.saleAmt = salePric;
		    
		    // 强制更新视图
		    this.$forceUpdate();
		  },
			
		  // 打开新增供应商对话框
		    openAddSupplierDialog() {
		      this.addSupplierDialogVisible = true;
		      this.supplierForm = {
		       supplierName: '',
		       contact: '',
		       contactPhone: '',
		       permitNumber: '',
		       address: '',
		       status: 1, // 默认启用
		       remark: ''
		      };
		    },
		    
		    // 关闭供应商对话框
		    handleSupplierDialogClose(done) {
		      done();
		    },
		    
		  // 保存供应商 / 提交表单
		  async handleSubmit() {
		    this.$refs.supplierForm.validate(async (valid) => {
		      if (valid) {
		        this.loading = true;
		        try {
		          // 调用新增供应商API
		          let res = await addSupplierEntity(this.supplierForm);
		          
		          if (res.code === 200) {
		            this.$message.success(res.message);
		            
		            // 1. 关闭新增供应商对话框
		            this.addSupplierDialogVisible = false;
		            
		            // 2. 重新加载供应商列表
		            await this.getGys();
		            
		            // 3. 自动选择新添加的供应商
		            if (res.data && res.data.id) {
		              this.addForm.supplierId = res.data.id;
		              this.$message.success(`已自动选择新增供应商: ${res.data.name}`);
		            }
		            
		            // 4. 重置供应商表单
		            this.supplierForm = {
		              supplierName: '',
		              contact: '',
		              contactPhone: '',
		              permitNumber: '',
		              address: '',
		              status: 1, // 默认启用
		              remark: ''
		            };
		            
		            // 5. 清除表单验证状态
		            this.$nextTick(() => {
		              if (this.$refs.supplierForm) {
		                this.$refs.supplierForm.clearValidate();
		              }
		            });
		          } else {
		            this.$message.error(res.message || '新增失败');
		          }
		        } catch (error) {
		          console.error('保存供应商出错:', error);
		          this.$message.error('保存供应商失败');
		        } finally {
		          this.loading = false;
		        }
		      }
		    });
		  },
		  // 添加检查并禁用重复生产厂家的方法
		  checkAndDisableManufacturers() {
		    if (!this.addMainForm.drugId) return;
		    
		    // 1. 获取当前表格中相同药品的厂家ID列表
		    const disabledManufacturerIds = this.tableData
		      .filter(item => item.drugId === this.addMainForm.drugId && 
		                     item.drugName === this.addMainForm.drugName)
		      .map(item => item.prodentpNameId);
		    
		    // 2. 更新生产厂家下拉选项的禁用状态
		    this.prodentOption = this.prodentOption.map(item => ({
		      ...item,
		      disabled: disabledManufacturerIds.includes(item.id)
		    }));
		    
		    // 3. 如果当前选择的生产厂家已被禁用，则清空选择
		    if (this.addMainForm.prodentpNameId && 
		        disabledManufacturerIds.includes(this.addMainForm.prodentpNameId)) {
		      this.addMainForm.prodentpName = '';
		      this.addMainForm.prodentpNameId = '';
		      this.$message.warning('该生产厂家已在表格中存在，请选择其他厂家');
		    }
		    
		    // 强制更新视图
		    this.$forceUpdate();
		  },
		  
		  // 添加表格行类名方法
		    tableRowClassName({row, rowIndex}) {
		      // 可以根据行数据或行索引添加不同的类名
		      if (row.editing) {
		        return 'editing-row'; // 正在编辑的行
		      }
		      if (rowIndex % 2 === 0) {
		        return 'even-row'; // 偶数行
		      } else {
		        return 'odd-row'; // 奇数行
		      }
		      // 也可以根据其他条件返回不同的类名
		      return '';
		    },
			
		  // 处理库存类型变化
		  handlePurcTypeChange(val) {
		    if (!this.addMainForm.pacCnt) return;
		    
		    if (val === '1') {
		      // 最小单位
		      this.addMainForm.minPurcPric = (Number(this.addMainForm.purcPric) / this.addMainForm.pacCnt).toFixed(2);
		      this.addMainForm.minSalePric = (Number(this.addMainForm.salePric) / this.addMainForm.pacCnt).toFixed(2);
		    } else {
		      // 包装单位
		      this.addMainForm.maxPurcPric = Number(this.addMainForm.purcPric).toFixed(2);
		      this.addMainForm.maxSalePric = Number(this.addMainForm.salePric).toFixed(2);
		    }
		  },
		
		  // 处理入库数量变化
		  handlePurcCntChange(val) {
		    if (this.addMainForm.purcPric && this.addMainForm.purcPric > 0) {
		      // 重新计算金额
		      this.addMainForm.purcAmt = (Number(this.addMainForm.purcPric) * val).toFixed(2);
		      this.addMainForm.saleAmt = (Number(this.addMainForm.salePric) * val).toFixed(2);
		    }
		  },
		// 取消高亮
		setCurrent(row) {
		    this.$refs.singleTable.setCurrentRow(row);
		},
		// 内层选择数据按钮
		async chooseData() {
		  if (this.currentTable.length === 0) {
		    this.$message({ type: 'warning', message: '请先选择一条数据!' });
		    return;
		  }
		
		  this.loading = true;
		  try {
		    const res = await getPlanData({ id: this.appId });
		    if (res.code === 200) {
		      // 处理新数据 - 计算各种单价
		      const newData = res.data.list.map(item => {
		        // 计算最小单位成本单价
		        const minPurcPric = item.purcPric / item.pacCnt;
		        // 计算最小单位销售单价
		        const minSalePric = (item.purcPric * (item.markUpRate || 1)) / item.pacCnt;
		        
		        return {
		          ...item,
				  putinTypeId:1,
		          // 最小单位价格
		          minPurcPric: minPurcPric.toFixed(2),
		          minSalePric: minSalePric.toFixed(2),
		          // 包装单位价格（原价）
		          maxPurcPric: item.purcPric,
		          maxSalePric: (item.purcPric * (item.markUpRate || 1)).toFixed(2),
		          // 金额计算
		          salePric: (item.purcPric * (item.markUpRate || 1)).toFixed(2),
		          purcAmt: (item.purcPric * item.purcCnt).toFixed(2),
		          saleAmt: (item.purcPric * (item.markUpRate || 1) * item.purcCnt).toFixed(2),
		          isEdit: false
		        };
		      });
		
		      // 检查是否有重复数据
		      const duplicates = [];
		      newData.forEach(newItem => {
		        const existingItem = this.tableData.find(
		          item => item.drugId === newItem.drugId && item.drugName === newItem.drugName
		        );
		        if (existingItem) {
		          duplicates.push({
		            newItem,
		            existingItem
		          });
		        }
		      });
		
		      if (duplicates.length > 0) {
		        // 询问用户是否合并
		        this.$confirm(`发现${duplicates.length}条重复数据，是否合并追加数量？`, '提示', {
		          confirmButtonText: '合并',
		          cancelButtonText: '不合并',
		          type: 'warning'
		        }).then(() => {
		          // 合并数据
		          duplicates.forEach(({ newItem, existingItem }) => {
		            existingItem.purcCnt = Number(existingItem.purcCnt) + Number(newItem.purcCnt);
		            existingItem.purcAmt = (existingItem.purcPric * existingItem.purcCnt).toFixed(2);
		            existingItem.saleAmt = (existingItem.salePric * existingItem.purcCnt).toFixed(2);
		          });
		
		          // 添加非重复数据
		          const nonDuplicates = newData.filter(newItem => 
		            !this.tableData.some(item => item.drugId === newItem.drugId && item.drugName === newItem.drugName)
		          );
		          this.tableData = [...this.tableData, ...nonDuplicates];
		          
		          // 重新计算合计金额
		          this.calculateTotals();
		          
		          // 更新行号
		          this.updateRowNumbers();
		          
		          this.$message.success('数据已合并');
		          this.innerVisible = false;
		        }).catch(() => {
		          // 不合并，直接添加所有数据
		          this.tableData = [...this.tableData, ...newData];
		          
		          // 重新计算合计金额
		          this.calculateTotals();
		          
		          // 更新行号
		          this.updateRowNumbers();
		          
		          this.$message.info('已添加新数据，未合并重复项');
		          this.innerVisible = false;
		        });
		      } else {
		        // 没有重复数据，直接添加
		        this.tableData = [...this.tableData, ...newData];
		        
		        // 重新计算合计金额
		        this.calculateTotals();
		        
		        // 更新行号
		        this.updateRowNumbers();
		        
		        this.$message.success('数据加载成功');
		        this.innerVisible = false;
		      }
		    } else {
		      this.$message.error(res.message);
		    }
		  } catch (error) {
		    console.error('获取数据出错:', error);
		    this.$message.error('获取数据失败');
		  } finally {
		    this.loading = false;
		  }
		},
		// 计算所有价格的方法
		  calculateAllPrices() {
		    if (!this.addMainForm.purcPric || !this.addMainForm.purcCnt) return;
		
		    // 获取当前药品信息
		    const drugInfos = this.filteredNameOption.find(item => item.id === this.addMainForm.drugId);
		    if (!drugInfos) return;
		
		    // 计算小单位成本单价
		    this.addMainForm.minPurcPric = (this.addMainForm.purcPric / drugInfos.pacCnt).toFixed(2);
		    
		    // 大单位成本单价就是原始成本价
		    this.addMainForm.maxPurcPric = this.addMainForm.purcPric.toFixed(2);
		
		    // 根据加成方式计算销售价格
		    switch(drugInfos.markUpId) {
		      case 0: // 不加成
		        this.addMainForm.salePric = this.addMainForm.purcPric;
		        this.MarkUpTitle = '不加成';
		        this.MarkUp = 1;
		        break;
		        
		      case 1: // 比例加成
		        this.addMainForm.salePric = this.addMainForm.purcPric * (1 + drugInfos.markUpRate);
		        this.MarkUpTitle = '比例加成:';
		        this.MarkUp = drugInfos.markUpRate;
		        break;
		        
		      case 2: // 固定加成
		        this.addMainForm.salePric = this.addMainForm.purcPric + drugInfos.markUpPric;
		        this.MarkUpTitle = '固定加成金额:';
		        this.MarkUp = drugInfos.markUpPric;
		        break;
		        
		      case 3: // 手工比例加成
		        this.addMainForm.salePric = this.addMainForm.purcPric + this.addMainForm.purcPric * (parseFloat(this.addForm.markUpRate) / 100);
		        this.MarkUpTitle = '手工比例加成:';
		        this.MarkUp = drugInfos.markUpRate;
		        break;
		        
		      default:
		        console.warn('未知的加成方式:', drugInfos.markUpId);
		        this.addMainForm.salePric = this.addMainForm.purcPric * 1;
		        this.MarkUpTitle = '默认不加成';
		        this.MarkUp = 1;
		    }
		    
		    // 计算小单位销售单价
		    this.addMainForm.minSalePric = (this.addMainForm.salePric / drugInfos.pacCnt).toFixed(2);
		    
		    // 大单位销售单价
		    this.addMainForm.maxSalePric = this.addMainForm.salePric.toFixed(2);
		    
		    // 计算金额
		    this.addMainForm.purcAmt = (this.addMainForm.purcPric * this.addMainForm.purcCnt).toFixed(2);
		    this.addMainForm.saleAmt = (this.addMainForm.salePric * this.addMainForm.purcCnt).toFixed(2);
		  },

		// 计算总金额的方法
		calculateTotals() {
		  // 重置合计金额
		  this.cbValue = '0.00';
		  this.lsValue = '0.00';
		  
		  // 遍历表格数据累加金额
		  this.tableData.forEach(item => {
		    // 确保金额是有效的数字
		    const purcAmt = Number(item.purcAmt) || 0;
		    const saleAmt = Number(item.saleAmt) || 0;
		    
		    this.cbValue = (Number(this.cbValue) + purcAmt).toFixed(2);
		    this.lsValue = (Number(this.lsValue) + saleAmt).toFixed(2);
		  });
		  
		  // 更新表单中的合计金额
		  this.addForm.costAmt = this.cbValue;
		  this.addForm.saleAmt = this.lsValue;
		},
		
		// 更新行号的方法
		updateRowNumbers() {
		  this.tableData.forEach((item, index) => {
		    this.$set(item, 'rowNumber', index + 1);
		  });
		},
		
		// 在handleAmountChange方法中调用calculateTotals
		handleAmountChange(row) {
		  // 确保数量和单价是有效的数字
		  const purcCnt = Number(row.purcCnt) || 0;
		  const purcPric = Number(row.purcPric) || 0;
		  const salePric = Number(row.salePric) || 0;
		  
		  // 计算金额
		  row.purcAmt = (purcPric * purcCnt).toFixed(2);
		  row.saleAmt = (salePric * purcCnt).toFixed(2);
		  
		  // 重新计算合计金额
		  this.calculateTotals();
		},
		// 表单主体聚焦事件 => addMainForm
		async foucsSelect(v,i){
			// val.id = i;
			this.idx = i;
			switch (i) {
				
			}
		},
		handleInput(v,i){
			this.idx = i;
			// i event
			switch (i) {
				case 9:
					this.getTotalAmt();
				break;
			}
		},
		sname(v,i){
			switch(i){
				case 5:
					this.getGys();
				break;
			}
		},
		
		// 计算总成本和零售合计
		getTotalAmt() {
			let cbTotal = 0;
			let lsTotal = 0;
			if(this.tableData.length === 0){
				this.addForm.costAmt = this.addMainForm.purcAmt = this.addMainForm.purcPric * this.addMainForm.purcCnt // 成本金额
				this.addForm.saleAmt = this.addMainForm.saleAmt = this.addMainForm.salePric * this.addMainForm.purcCnt // 零售金额
				this.cbValue = this.addForm.costAmt;
				this.lsValue = this.addForm.saleAmt;
			}else{
				this.addForm.costAmt = this.addMainForm.purcAmt = this.addMainForm.purcPric * this.addMainForm.purcCnt // 成本金额
				this.addForm.saleAmt = this.addMainForm.saleAmt = this.addMainForm.salePric * this.addMainForm.purcCnt // 零售金额
				this.tableData.forEach(row => {
					cbTotal += row.purcAmt;
					lsTotal += row.saleAmt;
				});
				this.addForm.costAmt = this.cbValue = cbTotal;
				this.addForm.saleAmt = this.lsValue = lsTotal;
			}
		},
		
		// 循环加入按钮点击事件
		// 修改clickEvents方法中的加入按钮逻辑
		clickEvents(val, i) {
		  this.idx = i;
		  switch (i) {
		    case 14: // 加入按钮
		      this.$refs.addMainForm.validate(async (valid) => {
		        if (valid) {
		          // 检查并禁用重复的生产厂家
		          this.checkAndDisableManufacturers();
		          
		          // 检查是否选择了已禁用的生产厂家
		          const selectedManufacturer = this.prodentOption.find(
		            item => item.id === this.addMainForm.prodentpNameId
		          );
		          
		          if (selectedManufacturer && selectedManufacturer.disabled) {
		            this.$message.error('该生产厂家已在表格中存在，请选择其他厂家');
		            return;
		          }
		          
		          // 直接添加新数据
		          this.addNewDrugData();
		          this.$message.success('已添加！');
		          
		          // 更新行号
		          this.updateRowNumbers();
		          // 计算总金额
		          this.calculateTotals();
		          
		          // 再次检查并禁用重复的生产厂家
		          this.checkAndDisableManufacturers();
		        }
		      });
		      break;
		  }
		},
		
		// 添加合并药品数据的方法
		// 修改合并数据方法
		mergeDrugData(duplicateIndex) {
		  const existingItem = this.tableData[duplicateIndex];
		  const newItem = this.addMainForm;
		  
		  // 确保药品ID或名称匹配
		  if (existingItem.drugId !== newItem.drugId && 
		      existingItem.drugName !== newItem.drugName) {
		    this.$message.error('药品不匹配，无法合并');
		    return;
		  }
		  
		  // 确保数量和单价是有效的数字
		  const existingPurcCnt = Number(existingItem.purcCnt) || 0;
		  const newPurcCnt = Number(newItem.purcCnt) || 0;
		  const existingPurcPric = Number(existingItem.purcPric) || 0;
		  const newPurcPric = Number(newItem.purcPric) || 0;
		  const existingSalePric = Number(existingItem.salePric) || 0;
		  const newSalePric = Number(newItem.salePric) || 0;
		  
		  // 合并数量
		  existingItem.purcCnt = existingPurcCnt + newPurcCnt;
		  
		  // 合并单价（取加权平均值）
		  const totalCnt = existingPurcCnt + newPurcCnt;
		  existingItem.purcPric = (
		    (existingPurcPric * existingPurcCnt + newPurcPric * newPurcCnt) / 
		    totalCnt
		  ).toFixed(2);
		  
		  existingItem.salePric = (
		    (existingSalePric * existingPurcCnt + newSalePric * newPurcCnt) / 
		    totalCnt
		  ).toFixed(2);
		  
		  // 重新计算金额
		  existingItem.purcAmt = (Number(existingItem.purcPric) * existingItem.purcCnt).toFixed(2);
		  existingItem.saleAmt = (Number(existingItem.salePric) * existingItem.purcCnt).toFixed(2);
		  
		  // 更新表格数据
		  this.$set(this.tableData, duplicateIndex, existingItem);
		  
		  // 重置表单
		  this.$refs.addMainForm.resetFields();
		  
		  // 重新计算合计金额
		  this.calculateTotals();
		  
		  // 强制更新视图
		  this.$forceUpdate();
		},
		
		// 修改addNewDrugData方法
		addNewDrugData() {
		  // 深拷贝表单数据
		  const newData = JSON.parse(JSON.stringify(this.addMainForm));
		  
		  // 确保金额是有效的数字
		  const purcPric = Number(newData.purcPric) || 0;
		  const salePric = Number(newData.salePric) || 0;
		  const purcCnt = Number(newData.purcCnt) || 0;
		  
		  // 计算金额
		  newData.purcAmt = (purcPric * purcCnt).toFixed(2);
		  newData.saleAmt = (salePric * purcCnt).toFixed(2);
		  
		  // 添加到表格
		  this.tableData.push(newData);
		  
		  // 重置表单
		  this.$refs.addMainForm.resetFields();
		  
		  // 重新计算合计金额
		  this.calculateTotals();
		  
		  // 强制更新视图，确保下拉选项状态正确
		  this.$forceUpdate();
		},
		// 启用编辑状态（直接在表格行中编辑）
		  enableEditing(row) {
		    // 保存原始数据用于取消编辑时恢复
		    // this.$set(row, '_originalData', JSON.parse(JSON.stringify(row)));
		    // this.$set(row, 'editing', true);
			
			// 保存原始数据用于取消编辑时恢复
			  this.$set(row, '_originalData', JSON.parse(JSON.stringify(row)));
			  this.$set(row, 'editing', true);
			  this.isEditing = true; // 进入编辑状态，禁用底部按钮
		  },
		  
		  // 保存编辑
		  saveEdit(row) {
		    // 验证必填字段
		      if (!row.manuLotnum || !row.manuDate || !row.expyDate || !row.purcCnt) {
		        this.$message.error('请填写所有必填字段！');
		        return;
		      }
		      
		      // 验证入库数量为正整数
		      if (!/^[1-9]\d*$/.test(row.purcCnt)) {
		        this.$message.error('入库数量必须为正整数！');
		        return;
		      }
		      
		      // 重新计算金额
		      row.purcAmt = (row.purcPric * row.purcCnt).toFixed(2);
		      row.saleAmt = (row.salePric * row.purcCnt).toFixed(2);
		      
		      // 退出编辑状态
		      row.editing = false;
		      delete row._originalData;
		      this.isEditing = false; // 退出编辑状态，启用底部按钮
		      
		      // 重新计算合计金额
		      this.calculateTotals();
		      
		      this.$message.success('保存成功');
		  },
		  
		 // 取消编辑
		 cancelEdit(row) {
		   if (row._originalData) {
		     Object.assign(row, row._originalData);
		     delete row._originalData;
		   }
		   row.editing = false;
		   this.isEditing = false; // 退出编辑状态，启用底部按钮
		 },
		  
		  // 计算合计金额
		 
		// // 取消编辑
		// cancelEdit(row) {
		//   // 恢复原始数据
		//   this.formMainType[15].disabled = false;
		//   Object.assign(row, row.originalData);
		//   this.$set(row, 'editing', false);
		//   delete row.originalData;
		//   // 清除监听
		//   this.$off('addMainForm');
		// },
		
		// 处理输入变化
		handleInputChange(row) {
		  // 重新计算总金额
		  this.addForm.costAmt = row.purcAmt = row.purcPric * row.purcCnt;
		  this.addForm.saleAmt = row.saleAmt = row.salePric * row.purcCnt;
		  this.getTotalAmt();
		},
		gotoPrice(v){
			if(v.length > 5){
				this.$message({type: 'error',message: '有效数量长度最高暂时为5位数...' });
			}
		},
		// 库存类型选择
		SelectedPurcType(val){
			this.addMainForm.purcType = val
			console.log(val,'valvalval');
			if(this.addMainForm.purcType == 1 || this.addMainForm.purcType == '1'){
				this.addMainForm.minPurcPric = this.addMainForm.purcPric / this.addMainForm.pacCnt // 最小单位成本单价
				this.addMainForm.minSalePric = this.addMainForm.salePric / this.addMainForm.pacCnt // 最小单位销售单价
			}else if(this.addMainForm.purcType == 2 || this.addMainForm.purcType == '2'){
				this.addMainForm.maxPurcPric = this.addMainForm.purcPric; // 最大单位成本单价
				this.addMainForm.maxSalePric = this.addMainForm.salePric; // 最大单位销售单价
			}
		},
		//新增保存
		// 修改保存提交方法
		async addSubmit() {
		  this.$refs.addForm.validate(async (valid) => {
		    if (valid) {
		      this.addForm.state = 2;
		      this.addForm.list = this.tableData;
		      this.addForm.costAmt = this.cbValue;
		      this.addForm.saleAmt = this.lsValue;
		      
		      if (this.tableData.length === 0) {
		        this.$message.error('暂无对应的单据明细...');
		        return;
		      }
		
		      this.loading = true;
		      try {
		        const result = await dugDocInsert(this.addForm);
		        if (result.code === 200) {
		          this.$message.success(result.message);
		          // 重置所有表单
		          this.resetAllForms();
		          this.addDialogVisible = false;
		          this.reload(); // 刷新父组件
		        } else {
		          this.$message.error(result.message);
		        }
		      } finally {
		        this.loading = false;
		      }
		    }
		  });
		},
		
		// 修改草稿保存方法
		async draftSubmit() {
		  this.$refs.addForm.validate(async (valid) => {
		    if (valid) {
		      this.addForm.state = 0;
		      this.addForm.list = this.tableData;
		      this.addForm.costAmt = this.cbValue;
		      this.addForm.saleAmt = this.lsValue;
		
		      this.loading = true;
		      try {
		        const result = await dugDocInsert(this.addForm);
		        if (result.code === 200) {
		          this.$message.success(result.message);
		          // 重置所有表单
		          this.resetAllForms();
		          this.addDialogVisible = false;
		          this.reload(); // 刷新父组件
		        } else {
		          this.$message.error(result.message);
		        }
		      } finally {
		        this.loading = false;
		      }
		    }
		  });
		},
		
		// 添加resetAllForms方法
		resetAllForms() {
		  // 1. 保存需要保留的数据（如当前用户ID等）
		  const currentUser = this.addForm.createId;
		  const terminalId = this.addForm.terminalId;
		  
		  // 2. 完全重置addForm和addMainForm
		  this.addForm = JSON.parse(JSON.stringify(addForm[0])); // 深拷贝初始表单
		  this.addMainForm = JSON.parse(JSON.stringify(this.addForm.list[0])); // 深拷贝初始明细表单
		  
		  // 3. 清空表格数据
		  this.tableData = [];
		  
		  // 4. 重置金额合计
		  this.cbValue = '0.00';
		  this.lsValue = '0.00';
		  this.purcType = '2';
		  this.isEditing = false;
		  
		  // 5. 重置对话框状态
		  this.isEditShow = false;
		  this.nameTitle = '新增【西药房】其他入库';
		  
		  // 6. 保留必要的数据
		  this.addForm.createId = currentUser;
		  this.addForm.terminalId = terminalId;
		  this.addForm.busDate = new Date().toISOString().split('T')[0];
		  this.addForm.createTime = new Date().toISOString().split('T')[0];
		  
		  // 7. 重置表单引用
		  if (this.$refs.addForm) {
		    this.$refs.addForm.resetFields();
		  }
		  if (this.$refs.addMainForm) {
		    this.$refs.addMainForm.resetFields();
		  }
		  
		  // 8. 强制更新视图
		  this.$forceUpdate();
		},
		// 草稿保存
		// async draftSubmit(){
		// 	//触发验证表单
		// 	this.$refs.addForm.validate(async(valid) => {
		// 	if(valid){
		// 	this.addForm.state = 0
		// 	this.addForm.list = this.tableData
		// 	this.addForm.costAmt = this.cbValue
		// 	this.addForm.saleAmt = this.lsValue
		// 	console.log(this.addForm,'草稿保存');
		// 	this.loading = true;
		// 	let result = await dugDocInsert(this.addForm);
		// 	if (result.code === 200) {
		// 		this.reload(); // 更新数据驱动 => 父组件 shopPlan
		// 		this.$message({ type: 'success', message: result.message });
		// 		this.loading = false;
		// 		this.addDialogVisible = false;
		// 		this.resetAllForms(); // 使用统一的重置方法
		// 	} else {
		// 		this.$message.error(result.message);
		// 		this.loading = false;
		// 	}
		// 	}
		// 	})
		// },
		// 修改编辑提交方法
		async editSubmit() {
		  this.$refs.addForm.validate(async (valid) => {
		    if (valid) {
		      this.addForm.state = 2;
		      this.addForm.list = this.tableData;
		      this.addForm.costAmt = this.cbValue;
		      this.addForm.saleAmt = this.lsValue;
		
		      if (this.tableData.length === 0) {
		        this.$message.error('暂无对应的单据明细...');
		        return;
		      }
		
		      this.loading = true;
		      try {
		        const result = await editdugDoc(this.addForm);
		        if (result.code === 200) {
		          this.$message.success(result.message);
		          // 重置所有表单
		          this.resetAllForms();
		          this.addDialogVisible = false;
		          this.reload(); // 刷新父组件
		        } else {
		          this.$message.error(result.message);
		        }
		      } finally {
		        this.loading = false;
		      }
		    }
		  });
		},
		// 修改草稿保存
		async draftEditSubmit(){
			//触发验证表单
			this.$refs.addForm.validate(async(valid) => {
			if(valid){
			this.addForm.state = 0
			this.addForm.list = this.tableData
			this.addForm.costAmt = this.cbValue
			this.addForm.saleAmt = this.lsValue
			console.log(this.addForm);
			this.loading = true;
			let result = await editdugDoc(this.addForm)
				if (result.code === 200) {
					this.reload(); // 更新数据驱动 => 父组件 shopPlan
					this.$message({ type: 'success', message: result.message });
					this.loading = false;
					this.addDialogVisible = false;
					// 清空表格表单
					this.resetAllForms(); // 使用统一的重置方法
				} else {
					this.loading = false;
					this.$message.error(result.message)
				}
			}
			})
		},
		// // 清空表格表单
		// clearForms(){
		// 	this.tableData = [];
		// 	this.cbValue = '';
		// 	this.lsValue = '';
		// 	this.$refs['addForm'].resetFields();
		// },
		// 在methods中添加一个统一的重置表单方法
		// 重置所有表单和数据
		// resetAllForms() {
		//   // 1. 保存需要保留的数据（如当前用户ID等）
		//   const currentUser = this.addForm.createId;
		//   const terminalId = this.addForm.terminalId;
		  
		//   // 2. 使用resetFields方法重置表单
		//   if (this.$refs.addForm) {
		//     this.$refs.addForm.resetFields();
		//   }
		//   if (this.$refs.addMainForm) {
		//     this.$refs.addMainForm.resetFields();
		//   }
		  
		//   // 3. 手动重置其他数据
		//   this.tableData = [];
		//   this.cbValue = '0.00';
		//   this.lsValue = '0.00';
		//   this.purcType = '1';
		//   this.isEditing = false;
		  
		//   // 4. 重置对话框状态
		//   this.isEditShow = false;
		//   this.nameTitle = '新增西药采购入库';
		  
		//   // 5. 保留必要的数据
		//   this.$nextTick(() => {
		//     this.addForm.createId = currentUser;
		//     this.addForm.terminalId = terminalId;
		//     this.addForm.busDate = new Date().toISOString().split('T')[0];
		//     this.addForm.createTime = new Date().toISOString().split('T')[0];
		//   });
		// },
		// 查看单据数据
		async watchData(){
			// 先拿id对应的数据赋值
			this.loading = true;
			let res = await getPlanData({id:this.appId});
			console.log(res.data,'');
			if(res.code === 200){
				this.tableWatchDataDialog = true;
				this.tableWatchData = res.data.list;
				this.loading = false;
			} else {
				this.$message({ type: 'warning', message: res.message});
				this.loading = false;
				this.tableWatchDataDialog = false;
			}
		},
		// 日期选择
		dateChoose(i){
			switch(i){
				// 生产日期
				case 12:
					this.pickerOptions = this.manuDatePickerOptions
				break;
				// 有效日期
				case 13:
					this.pickerOptions = this.expyDatePickerOptions
				break;
			}
		},
		// 日期选择处理 = 生产日期 + 有效天数 -1天
		getDatePicker(v) {
		  console.log(v, '日期选择值');
		  console.log(this.expyDate, 'this.expyDate');
		  // 确保有生产日期和有效期天数
		  if (this.addMainForm.manuDate && this.expyDate) {
		    // 将生产日期字符串转换为Date对象
		    const manuDate = new Date(this.addMainForm.manuDate);
		    // 将有效期天数转换为毫秒数并相加，然后减去1天的毫秒数
		    const expyDate = new Date(manuDate.getTime() + (this.expyDate * 24 * 60 * 60 * 1000) - (24 * 60 * 60 * 1000));
		    
		    console.log(expyDate,'expyDateexpyDateexpyDate');
		    // 格式化为 yyyy-MM-dd 格式
		    const year = expyDate.getFullYear();
		    const month = String(expyDate.getMonth() + 1).padStart(2, '0');
		    const day = String(expyDate.getDate()).padStart(2, '0');
		    
		    // 更新有效期
		    this.addMainForm.expyDate = `${year}-${month}-${day}`;
		  }
		},
		// 生产厂家搜索框空白格处理
		removeAllSpaces(str) {
		  return str.trim().replace(/\s+/g, '');
		},
		// SelectVal to editForm
		// SelectVal to editForm
		handleChange(val) {
		  switch(this.idx) {
		    case 2: // 供货单位
		      let rs = this.gysOption.find(name => name.id === val)
		      this.addMainForm.supplierName = rs.supplierName
		      break;
		    // 添加生产厂家的处理
		    case 7: // 生产厂家
		      let manufacturer = this.prodentOption.find(item => item.id === val);
		      if (manufacturer) {
		        this.addMainForm.prodentpName = manufacturer.label; // 生产厂家名称
		        this.addMainForm.prodentpNameId = manufacturer.id; // 生产厂家ID
		        
		        // 如果药品有效期天数存在，则计算并设置有效期
		        if (this.expyDate && this.addMainForm.manuDate) {
		          const manuDate = new Date(this.addMainForm.manuDate);
		          const expyDate = new Date(manuDate.getTime() + (this.expyDate * 24 * 60 * 60 * 1000) - (24 * 60 * 60 * 1000));
		          
		          // 格式化为 yyyy-MM-dd
		          const year = expyDate.getFullYear();
		          const month = String(expyDate.getMonth() + 1).padStart(2, '0');
		          const day = String(expyDate.getDate()).padStart(2, '0');
		          
		          this.addMainForm.expyDate = `${year}-${month}-${day}`;
		        }
		      }
		      break;
		  }
		},
		// 父组件控制打开新增模态框
		async open(param) {
		  // 确保状态初始化
		  this.isMinimized = false; 
		  if(param.nameTitle == '新增' || param.nameTitle.includes('新增')){
		    this.addDialogVisible = true;
		    this.isShow = true;
		    this.isEditShow = false;
		    this.nameTitle = '新增【西药房】其他入库'
		    // 先重置所有表单
		    this.resetAllForms();
		  }else if(param.nameTitle == '编辑' || param.nameTitle.includes('修改')){
		    this.addDialogVisible = true;
		    this.isEditShow = true;
		    this.nameTitle = '编辑【西药房】其他入库'
		    let res = await dugDocgetDrugDetails({ id:param.id });
		    if(res.code === 200){
		      // 遍历 res.data 的所有键名
		      for (let key in res.data) {
		        // 检查键名是否在对象 A 中存在
		        if (this.addForm.hasOwnProperty(key)) {
		          // 如果存在，将 B 中的值更新到 A 中
		          this.addForm[key] = res.data[key];
		        }
		      }
		      this.tableData = this.addForm.list
		      this.cbValue = this.addForm.costAmt
		      this.lsValue = this.addForm.saleAmt
		      this.addForm.id = param.id
		      
		      // 确保药品数据已加载
		      await this.getDrugWare();
		      // 强制更新视图，确保下拉选项状态正确
		      this.$forceUpdate();
		    }
		  }
		},
		// 根据选择的id去查找id对应的对象
		foundObj(){
			let rs = this.gysOption.find(name => name.id === val)
			console.log(rs);
		},
		deleteRow(index, rows) {
		  // 减去被删除行的金额
		  this.loading = true;
		  setTimeout(()=>{
		    this.cbValue -= rows[index].purcAmt;
		    this.lsValue -= rows[index].saleAmt;
		    rows.splice(index, 1);
		    this.loading = false;
		    // 强制更新视图，确保下拉选项状态正确
		    this.$forceUpdate();
		  },888)
		},
		handleSelectCost(val) {
		  this.addForm.nativePlace = val.join(',')
		},
		// db events
		// 给单元格绑定横向和竖向的index，这样就能确定是哪一个单元格
		tableCellClassName({row, column, rowIndex, columnIndex}){
			row.index = rowIndex;
			column.index = columnIndex;
		},
		// 当input失去焦点的时候，隐藏input
		hideInput(){
		    this.currentCell = null;
		},
		// db events
		handledbRow(row, column, event){
			if(row){ this.addForm = row; this.watchDialogVisible = true } else { console.log('fail'); }
			// console.log(this.addForm);
			this.formdisabled = true
		},
		// col 里面包含了表头字段和名称，list 是表格数据
		columnWidth(col, list) {
		  let prop = col.prop,lab = col.lab;
		  let width = 40; // 设定一个最小值
		  let maxlenStr = ""; // 最长字符串
		  for (let info of list) { if (maxlenStr < (info[prop] + "").length) maxlenStr = info[prop] }
		  width = Math.max(width, len(lab), len(maxlenStr));
		  // 表格自带的内边距(20px) 自调
		  return width + 24; // 这里加了 12px
		  function len(str) {
			// 实际分配长度可根据需要自行调整
			let length = 12;
			for (const char of str + "") {
			  // 英文小写字符 8px
			  if ("a" <= char && char <= "z") length += 8;
			  // 英文大写字符 8px
			  else if ("A" <= char && char <= "Z") length += 8;
			  // 中文字符 28px
			  else if (char >= "\u4e00" && char <= "\u9fa5") length += 28;
			  // 其他 8px
			  else length += 12;
			}
			return length;
		  }
		},
		// 内层
		innerColumnWidth(col, list){
			let prop = col.prop,lab = col.lab;
			let width = 28; // 设定一个最小值
			let maxlenStr = ""; // 最长字符串
			for (let info of list) { if (maxlenStr < (info[prop] + "").length) maxlenStr = info[prop] }
			width = Math.max(width, len(lab), len(maxlenStr));
			// 表格自带的内边距(20px) 自调
			return width + 24; // 这里加了 12px
			function len(str) {
				// 实际分配长度可根据需要自行调整
				let length = 12;
				for (const char of str + "") {
				  // 英文小写字符 8px
				  if ("a" <= char && char <= "z") length += 8;
				  // 英文大写字符 8px
				  else if ("A" <= char && char <= "Z") length += 8;
				  // 中文字符 22px
				  else if (char >= "\u4e00" && char <= "\u9fa5") length += 22;
				  // 其他 8px
				  else length += 12;
				}
				return length;
			}
		},
		// 查看单据
		WatchColumnWidth(col, list){
			let prop = col.prop,lab = col.lab;
			let width = 28; // 设定一个最小值
			let maxlenStr = ""; // 最长字符串
			for (let info of list) { if (maxlenStr < (info[prop] + "").length) maxlenStr = info[prop] }
			width = Math.max(width, len(lab), len(maxlenStr));
			// 表格自带的内边距(20px) 自调
			return width + 24; // 这里加了 12px
			function len(str) {
				// 实际分配长度可根据需要自行调整
				let length = 12;
				for (const char of str + "") {
				  // 英文小写字符 8px
				  if ("a" <= char && char <= "z") length += 8;
				  // 英文大写字符 8px
				  else if ("A" <= char && char <= "Z") length += 8;
				  // 中文字符 22px
				  else if (char >= "\u4e00" && char <= "\u9fa5") length += 22;
				  // 其他 8px
				  else length += 12;
				}
				return length;
			}
		},
		// 挂载或销毁前后重新赋值后端参数
		getAddForm() {
		  // 使用深拷贝初始化表单，避免引用问题
		  this.addForm = JSON.parse(JSON.stringify(addForm[0]));
		  this.addMainForm = JSON.parse(JSON.stringify(this.addForm.list[0]));
		  
		  // 定义数据来源
		  this.formType = AccType.map(val => ({...val}));
		  this.formMainType = AccMainType.map(val => ({...val}));
		},
		//分页
		//每页条数改变触发
		handleSizeChange(val) {
			this.pageNum = val;
			this.loadData();
		},
		//当前条数改变触发
		handleCurrentChange(val) {
			this.pageNum = val;
			this.loadData();
		},
		// 关闭最小化未保存清空的表单
		// 最小化对话框
		minimizeDialog() {
		  this.addDialogVisible = false;
		  this.isMinimized = true;
		},
		
		// 恢复对话框
		restoreDialog() {
		  this.addDialogVisible = true;
		  this.isMinimized = false;
		},
		// 编辑处理字符串包裹的纯数字类型
		convertNumericStrings(obj) {
		  if (typeof obj !== 'object' || obj === null) {
		    return obj; // 非对象直接返回
		  }
		
		  // 处理数组
		  if (Array.isArray(obj)) {
		    return obj.map(item => this.convertNumericStrings(item));
		  }
		
		  // 处理普通对象
		  const result = {};
		  for (const key in obj) {
		    if (obj.hasOwnProperty(key)) {
		      const value = obj[key];
		      if (typeof value === 'string' && /^\d+$/.test(value)) {
		        // 字符串全为数字，转换为数字类型
		        result[key] = Number(value);
		      } else if (typeof value === 'object') {
		        // 递归处理嵌套对象或数组
		        result[key] = this.convertNumericStrings(value);
		      } else {
		        // 其他情况直接保留
		        result[key] = value;
		      }
		    }
		  }
		  return result;
		},
		// 关闭
		handleClose(done) {
		  this.$confirm('关闭此界面会清空现已选择的内容, 是否继续?', '提示', {
		    confirmButtonText: '确定',
		    cancelButtonText: '取消',
		    type: 'warning'
		  }).then(() => {
		    // 完全重置表单
		    this.resetAllForms();
		    done();
		  }).catch(() => {
		    this.$message({ type: 'info', message: '已取消' });          
		  });
		}
		
	},
	
}
</script>

<style lang="less" scoped>
	.dialog-header {
	  display: flex;
	  height: 28px;
	  justify-content: space-between;
	  align-items: center;
	  width: 100%;
	  span{
		  color: #fff;
		  font-size: 12px;
	  }
	  .header-buttons {
	    display: flex;
	    align-items: center;
	    
	    /deep/ .el-button {
	      padding: 0;
	      margin-left: 8px;
	      color: #fff;
	      
	      &:hover {
	        color: #409EFF;
	        background-color: transparent;
	      }
	    }
	  }
	}
	/* 表格行样式 */
	/deep/ .el-table .editing-row {
	  background-color: #f0f9eb; /* 编辑中的行背景色 */
	}
	
	/deep/ .el-table .even-row {
	  background-color: #fafafa; /* 偶数行背景色 */
	}
	
	/deep/ .el-table .odd-row {
	  background-color: #ffffff; /* 奇数行背景色 */
	}
/deep/ .el-select-dropdown__item {
	// height: 36px;
	// line-height: 14px;
	padding: 0;
	border: 1px solid #f1f1f1;
	display: flex;
	align-items: center;
	justify-content: start;
}
#optionItem {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	text-align: left;
	justify-content: space-around;
	span{
		padding-left: 8px;
		border: 1px solid #f1f1f1;
		display: inline-block;
		width: 128px;
		font-size: 12px;
		// height: 26px;
		// line-height: 26px;
		white-space: nowrap;      /* 禁止换行 */
		overflow: hidden;         /* 隐藏溢出内容 */
		text-overflow: ellipsis;  /* 溢出显示省略号 */
	}
}
.layout-app{
    width: 100%;
    height: 100%;
    display: flex;
	background-color: f8f8f8;
	/* 对话框样式 */
	.minimizable-dialog {
	  transition: all 0.3s;
	  transform: rotate(180deg);
	}
	.minimized-button {
	  transform: scale(1.1);
	  cursor: pointer;
	}
	.minimized-button {
	  position: fixed;
	  right: 20px;
	  bottom: 50%;
	  width: 40px;
	  height: 40px;
	  border-radius: 50%;
	  background-color: #409eff;
	  color: white;
	  display: flex;
	  justify-content: center;
	  align-items: center;
	  cursor: pointer;
	  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
	  z-index: 9999;
	  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	  animation: floatIn 0.3s;
	}
	@keyframes floatIn {
	  from {
	    transform: scale(0) translateY(100%);
	    opacity: 0;
	  }
	  to {
	    transform: scale(1) translateY(0);
	    opacity: 1;
	  }
	}
	
    .addAcc{
		// self
		/deep/ .el-dialog__header{
			padding: 4px;
			background-color: #007bb0;
		}
		/deep/ .el-dialog__title{
			color: #fff;
			font-size: 12px;
		}
		/deep/ .el-dialog__headerbtn{
			top: 10px;
		}
		/deep/ .el-dialog__body{
			padding: 10px;
		}
		/deep/ .el-dialog__headerbtn .el-dialog__close{
			color: #fff;
		}
		/deep/ .el-dialog__headerbtn .el-dialog__close:hover{
			background-color: brown;
		}
		/deep/ .el-table .cell{
			font-size: 12px;
			font-weight: 400;
			color: #0c0c0c;
			text-align: center;
		}
		/* 自定义高亮颜色 */
		::v-deep .el-table__body tr.current-row > td {
		  background-color: #00557f !important;
		  color: #f9f9f9; /* 可选：修改文字颜色 */
		}
		/deep/ .el-table .el-table__cell{
			padding: 8px 0;
		}
		// 选项卡
		.tabs{
			
			.tabsMain{
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				align-items: center;
				width: 100%;
				.table{
					width: 100%;
					margin-top: 12px;
				}
				.total{
					display: flex;
					height: 48px;
					align-items: center;
					span{
						font-size: 12px;
					}
				}
				// 第一层头部表单
				.headerForm{
					/deep/ .el-input{
						width: 100%;
					}
					/deep/ .el-form-item{
						margin-bottom: 6px;
					}
					/deep/ .el-select >.el-input{
						width: 100%;
					}
					border: 1px solid #EBEEF5;
					padding: 8px;
					/deep/ .el-form-item__label{
						display: flex;
						justify-content: start;
						font-size: 12px;
						padding: 0;
					}
					/deep/ .el-input--mini .el-input__inner{
						height: 26px;
					}
					/deep/ .el-select-dropdown__item{
						font-size: 12px;
					}
				}
				// 第二层主体表单
				.mainForm{
					/deep/ .el-select .el-input {
					    width: 100%;
					}
					
					/deep/ .input-with-select .el-input-group__prepend {
					    background-color: #fff;
					}
					/deep/ .el-date-editor.el-input, .el-date-editor.el-input__inner{
						width: 100%;
					}
					/deep/ .el-form-item{
						margin-bottom: 6px;
					}
					/deep/ .el-form-item__label{
						display: flex;
						justify-content: center;
						font-size: 12px;
						padding: 0;
					}
					/deep/ .el-select-dropdown__item{
						font-size: 12px;
					}
					/deep/ .el-input--mini .el-input__inner{
						height: 26px;
					}
					padding: 8px;
					margin-top: 8px;
					border: 1px solid #EBEEF5;
					/deep/ .el-select-dropdown__item{
						border: 1px solid #eeeeee;
						padding: 0;
						height: 28px;
						#optionItem {
							width: 100%;
							height: 100%;
							display: flex;
							align-items: center;
							text-align: center;
							justify-content: space-around;
							span{
								display: inline-block;
								font-size: 12px;
								// width: 168px;
								height: 40px;
								line-height: 40px;
								white-space: nowrap;      /* 禁止换行 */
								overflow: hidden;         /* 隐藏溢出内容 */
								text-overflow: ellipsis;  /* 溢出显示省略号 */
							}
						}
					}
				}
			}	
		}
		.dialog-footer{
			display: flex;
			justify-content: right;
		}
	}
	.innerModel{
		/deep/ .el-dialog__header{
				padding: 4px;
				line-height: 28px;
				background-color: #007bb0;
			}
			/deep/ .el-dialog__body{
				padding: 10px;
			}
			/deep/ .el-dialog__title{
				color: #fff;
				font-size: 12px;
			}
			/deep/ .el-dialog__headerbtn .el-dialog__close{
				color: #fff;
			}
			/deep/ .el-dialog__headerbtn .el-dialog__close:hover{
				background-color: brown;
			}
			/deep/ .el-table .cell{
				font-size: 12px;
				font-weight: 400;
				color: #0c0c0c;
				text-align: center;
			}
			/* 自定义高亮颜色 */
			::v-deep .el-table__body tr.current-row > td {
			  background-color: #00557f !important;
			  color: #f9f9f9; /* 可选：修改文字颜色 */
			}
			/deep/ .el-table .el-table__cell{
				padding: 8px 0;
			}
		.innerModel-header{
			display: flex;
			align-items: center;
		}
		.innerModel-table{
			/* 自定义高亮颜色 */
			::v-deep .el-table__body tr.current-row > td {
			  background-color: #00557f !important;
			  color: #f9f9f9; /* 可选：修改文字颜色 */
			}
		}
	}
	
}
</style>